
/**
 * 运行时配置文件
 */
import React from 'react';

export function patchRoutes({ routes }: any) {
    routes.unshift({
        path: '/user',
        exact: true,
        title: 'user title',
        component: require('@/pages/user').default,
    });
}

/** 路由切换 */
export function onRouteChange({ matchedRoutes }: any) {
    if (matchedRoutes.length) {
        /** 动态改变title */
        document.title = matchedRoutes[matchedRoutes.length - 1].route.title || '';
    }
}

/** 自定义容器 */
const AxContainer = (props: any) => (<div>AxContainer{props.children}</div>);
/** 渲染根容器 */
export function rootContainer(container: any) {
    return React.createElement(AxContainer, null, container);
}

// export const ssr = {
//     modifyGetInitialPropsCtx: async (ctx: any) => {
//         ctx.data = {
//             title: 'params'
//         };
//         return ctx;
//     }
// }